package com.rover.system.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.grid.ViewField;

/**
 * 菜单资源
 */
@Entity
@Table(name = "S_DEPARTMENT")
public class Department implements Serializable {


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@ViewField
    private Integer id;
	
	@ViewField(header = "部门编码", width = 200)
    private String deptCode;
	
	@ViewField(header = "部门名称", width = 200)
    private String deptName;
	
	@ViewField(header = "部门代码", width = 200)
    private String deptSn;
	
	@ViewField(header = "备注", width = 200)
    private String remark;
	
	private String 	pDeptCode;
	
    private Department pDepartment;
    private Set<Department> departments = new HashSet<Department>();
    
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY) 
	public Integer getId() {
		return id;
	}
    
	public void setId(Integer id) {
		this.id = id;
	}
	


	
	public String getRemark() {
		return remark;
	}
	
	public void setRemark(String remark) {
		this.remark = remark;
	}

	@ManyToOne(fetch = FetchType.EAGER,cascade =  CascadeType.REFRESH)
	@JoinColumn(name = "PID")
	public Department getpDepartment() {
		return pDepartment;
	}

	public void setpDepartment(Department pDepartment) {
		this.pDepartment = pDepartment;
	}

	@OneToMany(cascade={CascadeType.REFRESH,CascadeType.PERSIST,CascadeType.REMOVE,CascadeType.MERGE},fetch = FetchType.EAGER,mappedBy = "pDepartment")
	public Set<Department> getDepartments() {
		return departments;
	}

	public void setDepartments(Set<Department> departments) {
		this.departments = departments;
	}

	public void setDeptSn(String deptSn) {
		this.deptSn = deptSn;
	}

	public String getDeptSn() {
		return deptSn;
	}

	public String getDeptCode() {
		return deptCode;
	}

	public void setDeptCode(String deptCode) {
		this.deptCode = deptCode;
	}

	public String getDeptName() {
		return deptName;
	}

	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}

	public void setpDeptCode(String pDeptCode) {
		this.pDeptCode = pDeptCode;
	}
	 @Transient
	public String getpDeptCode() {
		return pDeptCode;
	}
	
    
}